<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>4_运算符</title>
</head>
<body>
<script>

    console.log(6+2)
    console.log(6/2)
    //如果比较运算符任意一边有数字会将字符串转为数字再比较
    console.log('6'>2)
    console.log(6<'2')
    //如果比较运算符左右两边都是字符串，则按照字符串的编码值比较
    console.log('a'>'A')
    console.log('a'>'a')
    console.log('宇'>'博')
    console.log('程晓宇'.charCodeAt());
    console.log('*****************************************************');
//Number()将参数转为数字，如果得不到数值类型的结果，则返回NaN
    console.log(Number('3'),typeof Number('3'));//3
    console.log(Number(true),typeof Number(true));//1
    console.log(Number(false),typeof Number(false));//0
    console.log(Number('你好'),typeof Number('你好'));//NaN

    let a = 1;
    let b = true;
    //松散比较运算符，只比较值，Number(true)=1
    console.log( a == b);//true
    //严格比较运算符，先比较类型再比较值
    console.log( a === b);//false

    //三元运算符/三目运算符
    let c = 0;
    console.log(c==0?'是':'否');
    console.log(c=0?'是':'否');


    //Boolean()将参数转为布尔类型的值
    //如果参数的值是0 空字符串 null undefined NaN 转为布尔都是false，其余都是true
    console.log(Boolean(0));
    console.log(Boolean(null));
    console.log(Boolean(undefined));
    console.log(Boolean(NaN));
    console.log(Boolean(''));
    console.log(Boolean(' '));
    console.log(Boolean('马上下课了'));


</script>
</body>
</html>